﻿<?php

//db.class.php

class DB{

	private $db;
	//private static  $host="localhost";
	//private static  $user="root";
	//private static  $pass="";
	//private static  $name="listen";
	
	private static  $host="10.4.26.93";
	private static  $user="uibjpUIjiMhuy";
	private static  $pass="pW7DQQRfAdRjZ";
	private static  $name="df7a68fe4d9d9478d97351d6b39f123ee";	

   public function __construct(){     
       $this->db=new mysqli(self::$host,self::$user,self::$pass,self::$name);
       if($this->db->connect_error){
	       echo "连接失败";
	   }
       $this->db->query("set name utf8");
   }


    
	//查询
    public function dql($sql){
	   $res=$this->db->query($sql);       
	   return $res;
	}
    
	//插入  删除  更新
	public function dml($sql){
       $res=$this->db->query($sql);       
       if(!$res){
	     //操作失败
	     return 0;
	   }else{
	      if($res->affected_rows()){
		     //没有函数受到影响
		     return 1;
		  }else{
		     //操作成功，有一行受到影响
		     return 2;
		  }
	    
	   }
	}

   //释放资源
   function close(){
   
   }


}


